﻿@model IEnumerable<Developer.Entity.Comments>
@{
    ViewBag.Title = "Index";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
    int i = 1;
}
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 评论管理 <span class="c-gray en">&gt;</span> 评论列表 <a class="btn btn-success radius r" id="btn-refresh" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="text-c">
        <form id="searchForm" action="/admin/comments/index" method="get">
            <input type="text" class="input-text" style="width: 250px" placeholder="输入评论内容关键字" id="username" name="name" value="@ViewBag.Name">
            <button type="submit" class="btn btn-success radius"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
        </form>
    </div>
    <div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"></span> <span class="r">共有数据：<strong>@ViewBag.itemCount</strong> 条</span> </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
                <tr class="text-c">
                    <th><input type="checkbox" name="" value=""></th>
                    <th>序号</th>
                    <th>评论内容</th>
                    <th>所评图书</th>
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {
                    <tr class="text-c">
                        <td><input type="checkbox" value="@item.Id" name="checkedList"></td>
                        <td id="companyId">@(i++)</td>
                        <td>@item.Contents</td>
                        <td><a href="/Book/Detail?bid=@(item.BookId)">@(item.Books.Name )</a></td>
                        <td>@item.CreateTime</td>
                        <td class="td-manage">
                            <a title="删除" href="javascript:;" onclick="sf_del('/admin/comments/Delete?cid=@(item.Id)')" class="ml-5 btn btn-primary radius" style="text-decoration: none">删除</a>
                        </td>
                    </tr>
                }
            </tbody>
        </table>
        <div id="adminPage"></div>
        <div style="clear:both;"></div>
    </div>
</div>
<script type="text/javascript">
    sf_page('adminPage', @ViewBag.pageCount);
    $(function() {
        $("#setVip")
            .click(function() {
                var isVip = $(this).parents("tr").find("td:eq(4)").text();
                var userId=$(this).parents("tr").find("input").val();
                console.log(isVip);
                if (isVip === "会员") {
                    layer.confirm("确认要把此用户设置为Vip会员吗？",
                        function() {
                            self.location = "/admin/user/setvip?Id=" + userId;
                        });
                } else {
                    layer.confirm("确认取消此用户的Vip会员吗？",
                        function() {
                            self.location = "/admin/user/setvip?Id=" + userId;
                        });
                }
            });
    });
</script>
